<?php
namespace app\admin\model;
use think\model;
use think\Db;
/**
 * Created by PhpStorm.
 * User: 戎大富
 * Date: 2018/8/13
 * Time: 10:37
 */
class InstitutionalactivitiesModel extends Model{
    protected $name = 'institutional_activities';
    /**
     * 根据搜索条件获取用户列表信息
     */
    public function getByWhere($od, $Num, $limit,$where)
    {
        return $this->alias ('a')
            ->join('up_mechanism um','um.mechanism_id = a.activity_mechanism_id','left')
            ->page($Num, $limit)
            ->field('a.*,um.mechanism_name')
            ->where($where)
            ->order($od)
            ->select();
    }
    
    /**
     * @param $where
     * @return array|false|\PDOStatement|string|Model
     */
    public function getOne($where)
    {
        return $this->where($where)->find();
    }
    public function batchDelBanner($param){
        Db::startTrans();// 启动事务
        $res = $this->where('banner_id','IN',$param)->delete();
        if($res){
            Db::commit();
            writelog(session('uid'),session('username'),'批量删除成功',1);
            return ['code' => 200, 'data' => '', 'msg' => '批量删除成功'];
        }else{
            Db::rollback();
            writelog(session('uid'),session('username'),'批量删除失败',2);
            return ['code' => 100, 'data' => '', 'msg' => '批量删除失败'];
        }
    }
}